Skip to content

Add video encode/decode round-trip sample - #27

Merged
dzhdanNV merged 61 commits into
NVIDIA-RTX:mainfrom
Daedie-git:codex/video-encode-decode-sample
Oct 22, 2026
Merged

dzhdanNV merged 61 commits into
NVIDIA-RTX:mainfrom
Daedie-git:codex/video-encode-decode-sample

Conversation

@Daedie-git

Copy link
Copy Markdown

Summary

Adds a VideoEncodeDecode sample that exercises the NRIVideo encode/decode round-trip path with a compute-generated animated NV12 source and a decoded preview.

The sample supports H.264, H.265, and AV1 via --codec, uses the same backend-agnostic NRIVideo flow for Vulkan and D3D12, and gates the target on NRI_VIDEO_VERSION >= 1 so older NRI trees skip cleanly instead of failing at compile time.

Details

  • Adds the animated NV12 generation/conversion shader and sample integration.
  • Creates video sessions, parameters, pictures, bitstream buffers, encode feedback readback, and decode submission through NRIVideo.
  • Uses Annex-B header generation for H.264/H.265 and AV1 encode-to-decode metadata preparation.
  • Uses aligned NV12 upload/readback layouts based on device texture-copy alignment requirements.
  • Displays separate generated-source and decoded-preview panels plus independent video/preview status text.

Validation

  • Built VideoEncodeDecode in Release.
  • Ran 12 sample configurations for 1000 frames each:
    • APIs: VULKAN, D3D12
    • Codecs: H264, H265, AV1
    • Modes: normal and --debugNRI --debugAPI
  • All sample runs exited 0 with no filtered error, Failed, Invalid, VUID, crash, or exception lines.
  • Built and ran Fury nri_video_tests: 69 tests run, 69 passed.

@Daedie-git
Daedie-git marked this pull request as ready for review May 5, 2026 22:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d9afd66d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Source/VideoEncodeDecode.cpp Outdated
Comment on lines +461 to +465
nri::QueueFamilyDesc queueFamilies[] = {
{nullptr, 1, nri::QueueType::GRAPHICS},
{nullptr, 1, nri::QueueType::VIDEO_ENCODE},
{nullptr, 1, nri::QueueType::VIDEO_DECODE},
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Defer requesting video queues until after capability checks

On adapters/backends that do not expose video encode or decode queues, this requests VIDEO_ENCODE and VIDEO_DECODE queues during nriCreateDevice, so initialization can fail before TryInitializeVideo() reaches its queueNum check and reports that video is unavailable. That makes the sample abort instead of running the graphics/preview path with a clear status on unsupported hardware; create the device with the graphics queue first, then request video queues only after confirming the adapter supports them.

Useful? React with 👍 / 👎.

@Daedie-git
Daedie-git force-pushed the codex/video-encode-decode-sample branch from 682a319 to b056394 Compare May 6, 2026 10:17
@Daedie-git
Daedie-git force-pushed the codex/video-encode-decode-sample branch from 9375a04 to e6195c3 Compare May 21, 2026 10:27
BjornSAIM added 17 commits June 21, 2026 11:37
Adds the VideoEncodeDecode sample with an animated compute-generated NV12 source, GPU encode/decode round-trip display, and CLI codec selection for H.264, H.265, and AV1.

Uses the backend-neutral NRIVideo flow across Vulkan and D3D12: video sessions and pictures, encode feedback readback, decode picture state queries, Annex-B header generation, AV1 metadata preparation, and aligned NV12 upload/readback layouts.

Integrates the sample into CMake, shader configuration, README, and NRI submodule expectations, gating the target on the required NRIVideo version so older NRI trees skip cleanly.
Point the NRIFramework submodule at the branch that uses NRI video-queues, remove the local NRI override documentation, and apply formatting cleanup to the video sample.
@Daedie-git
Daedie-git force-pushed the codex/video-encode-decode-sample branch from 860a482 to 8623cb9 Compare June 21, 2026 09:38
BjornSAIM and others added 18 commits October 14, 2026 20:27
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s the bottom partial CTB row)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e encode lists

Without lists_modification_present_flag the encode list order matters, but the decode RPS order must not (D3D12/VK sort by POC): the *-nolistmod cases now exercise the decode sorting too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ling list and PPS-id/B cases without list modification, --enhancedBarriers

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d from the Linux station tester's scratch patch)

The AV1 frame header comes from NRI's header parser; a reference NV12 file makes the decode bit-exact checked. Legacy D3D12 barriers unless VIDEO_SAMPLE_ENHANCED_BARRIERS is set.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…address the NV12 planes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…1/libaom) bit-exact against a reference

Runs on decode-only hardware (no AV1 encode). Parses the sequence header,
uses the NRI header parser for the frame headers, tracks the 8 reference slots
and SavedOrderHints, sets the decode picture extent to the AV1 frame size
(the texture is rounded up to the decode granularity; the mismatch made
NVIDIA decode gray / edge-different pictures).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…-encode-decode-sample' into test/combined/codex-video-encode-decode-sample

# Conflicts:
#	Source/VideoEncodeDecode.cpp
#	Source/VideoEncodeDecode/Stream.cpp
BBP streams signalled 1, so ffmpeg output the pictures in the wrong order (22 dB) while the NRI decode was right.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ts the passed references)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eference

The slice RPS lists only the picture own references, a decoder removes the
rest; the plan kept them and later pictures referenced missing POCs (ffmpeg:
Could not find ref with POC 0).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…-decode-sample' into test/combined/codex-video-encode-decode-sample
…e plan drops unreferenced DPB pictures itself)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r count from the plan, --enhancedBarriers for the headless paths, strict --decodeFile reference, NRI include dir from CMake

- remove --h265ScalingList / h265-scaling-default (encoders do not apply the lists)
- max_num_reorder_pics from GetReorderNum(plans) for --stream/--matrix and the interactive path
- RunEnvironment::enhancedBarriers reaches both headless device creations (decodeFile had none)
- decodeFile: reference keyed on the supplied path, length enforced, >= 1 decoded picture
- SharedVideo.h found through NRI_SOURCE_DIR instead of a relative path

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
BjornSAIM and others added 9 commits October 21, 2026 13:36
…code-sample

Updates NRIFramework/NRI to the aligned video test tip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D3D12 can't build AV1 decode info from a payload header (the payload has no
frame header) or without encode feedback; NRI reports UNSUPPORTED, which the
headless stream now reports as SKIP instead of FAIL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The payload header fallback is UNSUPPORTED on D3D12, so a real failure of the
metadata path became a SKIP. Only a case without any usable path is
unsupported now, and the metadata path, which needs the resolved metadata, is
not tried without encode feedback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inter frames that inherit state from reference frames (libaom inherits the
loop filter deltas of primary_ref_frame) need the state of the reference
slots; the stream keeps the 'savedFrameState' of every refreshed slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Streams with film_grain_params_present decode in a film grain session
('VideoSessionDesc::av1FilmGrain', textures with 'videoAV1FilmGrain'). The
output gets the film grain, the DPB keeps the picture without it. Without
advertised distinct mode (VK on NVIDIA) only pictures applying film grain
use the distinct output, the others decode with the DPB picture as output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep the sample changes and main's C API compatibility fixes. Resolve NRIFramework through a merge that retains source override support and uses upstream NRI main, including the video fixes.
@dzhdanNV

Copy link
Copy Markdown
Collaborator

Finally! It's happening now... Merged!

@dzhdanNV
dzhdanNV merged commit d15dfdb into NVIDIA-RTX:main Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants